package pub.xspace.nova.system.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.core.util.ObjectUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import pub.xspace.nova.common.controller.BaseController;
import pub.xspace.nova.common.domain.AjaxResult;
import pub.xspace.nova.system.domain.SysUser;
import pub.xspace.nova.system.service.SysUserService;

/**
 * 登陆相关功能 控制器
 * 
 * @author HeJianrong
 */
@RestController
@Slf4j
public class LoginController extends BaseController {

	@Resource
	private SysUserService sysUserService;
	
	@PostMapping("/login")
	public AjaxResult login(@RequestBody SysUser sysUser) {
		SysUser storeUser = sysUserService.login(sysUser);
		if(ObjectUtil.isEmpty(storeUser)) {
			return failure();
		}else {
			return success(storeUser);
		}
	}
	
}
